<?php

/*	LibFox - Simple library for XML-based backends.
	Copyright (C) 2008 LinFox Serviços em Informática LTDA.

	This file is part of LibFox.

	LibFox is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	LibFox is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>. */

require_once 'config_dao.php';

/**
 * Config class.
 * 
 * This isn't a model for config_dao,
 * but rather a simpleton-like class that will return an instance
 * of a model with all the site's configuration, using config_dao. 
 */
class config {

	/**
	 * Instance of the config object.
	 *
	 * @var object
	 */
	private static $instance;

	private function __construct() { }

	/**
	 * Returns instance of config.
	 * 
	 * Returns the current instance, or creates and returns it
	 * if it doesn't exist yet.
	 *
	 * @return model
	 */
	public static function get_instance() {
		if (empty(self::$instance)) {
			$config_dao = new config_dao();
			self::$instance = $config_dao->fetch('1');
		}
		return self::$instance;
	}
}

?>